

package com.jingdun.sport.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingdun.sport.bean.model.*;
import com.jingdun.sport.common.util.PageParam;
import com.jingdun.sport.dao.RoomMapper;
import com.jingdun.sport.service.RoomService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
@Slf4j
@AllArgsConstructor
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {

    private RoomMapper roomMapper;

    public void addRoom(Room room) {
        roomMapper.addRoom(room);
    }

    public Room getRoomDetail(@Param("params") Map<String, Object> m) {
        return roomMapper.getRoomDetail(m);
    }

    public Page<GetPaginationRoomByPrizeTypeResp> getPaginationRoomByPrizeType(@Param("params") Map<String, Object> m) {
        //新建分页
        Page<GetPaginationRoomByPrizeTypeResp> page = new Page<>((long) m.get("current"), (long) m.get("size"));
        //返回结果
        page.setRecords(this.baseMapper.getPaginationRoomByPrizeType(page, m));
        return page;
    }

    public Page<GetPaginationRoomByPrizeTypeResp> getPaginationRoomBySportCategory(Map m) {
        //新建分页
        Page<GetPaginationRoomByPrizeTypeResp> page = new Page<>((long) m.get("current"), (long) m.get("size"));
        //返回结果
        page.setRecords(this.roomMapper.getPaginationRoomBySportCategory(page, m));
        return page;
    }

    @Override
    public Map bonusPools() {
        return roomMapper.bonusPools();
    }

    @Override
    public Map getUserUnWithdrawalSum() {
        return roomMapper.getUserUnWithdrawalSum();
    }

    public void updateRoom(Room room) {
        roomMapper.updateRoom(room);
    }

    public List<Room> getRoomList(@Param("params") Map<String, Object> m) {
        return roomMapper.getRoomList(m);
    }

    @Override
    public List<Room> getUnfinishedRoomList(String today) {
        return roomMapper.getUnfinishedRoomList(today);
    }

    @Override
    public List<Room> getRoomListByActivityId(Set<Long> activityIdSet) {
        return roomMapper.getRoomListByActivityId(activityIdSet);
    }

    @Override
    public Room newGetById(Long roomId) {
        return roomMapper.newGetById(roomId);
    }

    @Override
    public NewSportConfig getByType(String sportCategory) {
        return roomMapper.getByType(sportCategory).get(0);
    }

    @Override
    public List<ListTypesResponse> getListTypes(Integer parent, PageParam pageParam) {
        return roomMapper.getListTypes(parent, pageParam);
    }
}
